# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=libkgapi
pkgver=22.04.3
pkgrel=0
pkgdesc="LibKGAPI is a KDE-based library for accessing various Google services via their public API"
# armhf blocked by extra-cmake-modules
# ppc64le, s390x and riscv64 blocked by qt5-qtwebengine
arch="all !armhf !ppc64le !s390x !riscv64"
url="https://community.kde.org/KDE_PIM"
license="LGPL-2.1-only OR LGPL-3.0-only"
depends_dev="
	cyrus-sasl-dev
	kcalendarcore-dev
	kcontacts-dev
	kio-dev
	kwallet-dev
	kwindowsystem-dev
	qt5-qtbase-dev
	qt5-qtwebengine-dev
	"
makedepends="$depends_dev
	extra-cmake-modules
	qt5-qttools-dev
	samurai
	"
checkdepends="xvfb-run"
source="https://download.kde.org/stable/release-service/$pkgver/src/libkgapi-$pkgver.tar.xz
	0001-fix-build.patch
	"
subpackages="$pkgname-dev $pkgname-lang"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	cd build
	# calendar-freebusyqueryjobtest, contacts-contactfetchjobtest,
	# contacts-contactcreatejobtest and contacts-contactmodifyjobtest are broken
	# tasks-taskfetchjobtest fails on the builders
	# contacts-contactfetchjobtest: https://gitlab.alpinelinux.org/alpine/aports/-/issues/11787
	# calendar-event-*: UTC+02 != UTC+02:00
	CTEST_OUTPUT_ON_FAILURE=TRUE xvfb-run ctest -E "(tasks-taskfetchjob|calendar-freebusyqueryjob|contacts-contact(fetchjob|createjob|modifyjob)|calendar-event(createjob|modifyjob|fetchjob))test"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
575a5aab6693510df7ea8949846e4de7d1d9e94264ee2075e66a5f0207a3078fcd9c8d1fa398f223476114487ac54fb88dab8d09e2166218831f55ee0326f38a  libkgapi-22.04.3.tar.xz
48ba9a974b10be0fe204a50ec15d7e48f17fa3d3211ad9a22ad0ca5742fd6121ed81563f59c57b6d618597c74e6b831dbc5f046baf64e41a4315663e09c5b74f  0001-fix-build.patch
"
